package com.gexiaobao.pigeon.ui.fragment.mine.organization.activity

import android.os.Bundle
import com.gexiaobao.pigeon.app.base.BaseActivity
import com.gexiaobao.pigeon.app.util.StatusBarUtil
import com.gexiaobao.pigeon.databinding.ActivityVisitAnnouncemenmtBinding
import com.gexiaobao.pigeon.viewmodel.OrgDetailViewModel
import me.hgj.jetpackmvvm.ext.util.setOnclickNoRepeat

/**
 * @Author      : hxw
 * @Date        : 2024/6/7 10:52
 * @Describe    : 探视公告
 */
class ActivityVisitAnnouncement : BaseActivity<OrgDetailViewModel, ActivityVisitAnnouncemenmtBinding>() {

    private var mRaceId = ""

    override fun initView(savedInstanceState: Bundle?) {
        StatusBarUtil.setTranslucentForImageView(this, 0, null)
        mDatabind.includeTitle.tvTitle.text = "探视公告"
        mRaceId = intent.getIntExtra("raceId", 0).toString()
        mViewModel.getVisitNotice(mRaceId)
    }

    override fun createObserver() {
        super.createObserver()
        mViewModel.visitNoticeResult.observe(this) {
            if (it != null) {
                val notice = it.notice
                initWebView(notice)
            }
        }
    }

    private fun initWebView(notice: String) {
        mDatabind.webViewVisitNotice.loadDataWithBaseURL(null, notice, "text/html", "utf-8", null)
    }

    override fun onBindViewClick() {
        super.onBindViewClick()
        setOnclickNoRepeat(mDatabind.includeTitle.ivBack) {
            when (it) {
                mDatabind.includeTitle.ivBack -> {
                    finish()
                }
            }
        }
    }
}